Skip to content

Conversation

@yepitschunked
Copy link

This was previously closed in #38255 due to inactivity. This PR has been updated with the feedback from @yury-s on the previous PR to avoid a bug with single set-cookie headers.

Following PR description is copied from the original:

Route.fulfill currently does not support multiple headers with the same name (#37342). There are workarounds when using this API directly (merging headers, tweaking the header name casing, etc.), but this is problematic for routeFromHAR, which depends on
this API internally. This patch adds special handling for set-cookie headers within harRouter to merge them into one header. There's some precedent for treating set-cookie specially at various places in the codebase (ex:

const sep = name.toLowerCase() === 'set-cookie' ? setCookieSeparator : separator;
,
function splitSetCookieHeader(headers: types.HeadersArray): types.HeadersArray {
), so I think this is okay.

Route.fulfill currently does not support multiple headers with the same
name (microsoft#37342). There are workarounds when using this API directly
(merging headers, tweaking the header name casing, etc.), but this is
problematic for routeFromHAR, which depends on
this API internally. This patch adds special handling for set-cookie
headers within harRouter to merge them into one header. There's some
precedent for treating set-cookie specially at various places in the
codebase (ex:
https://github.com/microsoft/playwright/blob/f54478a23e0daa450fe524905eabc8aabf6efb07/packages/playwright-core/src/utils/isomorphic/headers.ts#L29,
https://github.com/microsoft/playwright/blob/baeb065e9ea84502f347129a0b896a85d2a8dada/packages/playwright-core/src/server/chromium/crNetworkManager.ts#L675), so I think this is okay.
expect(await page2.evaluate(fetchFunction, { path: '/echo', body: '12' })).toBe('12');
});

it('should replay requests with multiple set-cookie headers properly', async ({ context, asset }) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this test is still necessary with the multi-cookie test below (seems like that one both records and replays a HAR)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove it and revert the manual changes to har-fulfill.har

expect(cookie2.split('; ').sort().join('; ')).toBe('first=foo');
});

it('should record multiple set-cookie headers', {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skn0tt Skn0tt requested a review from yury-s December 9, 2025 07:20
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

expect(await page2.evaluate(fetchFunction, { path: '/echo', body: '12' })).toBe('12');
});

it('should replay requests with multiple set-cookie headers properly', async ({ context, asset }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove it and revert the manual changes to har-fulfill.har

yepitschunked and others added 2 commits January 21, 2026 10:36
Co-authored-by: Yury Semikhatsky <yurys@chromium.org>
Signed-off-by: Victor Lin <125177+yepitschunked@users.noreply.github.com>
@yepitschunked
Copy link
Author

@yury-s took me a while due to the holidays - addressed your feedback on the tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert changes in this file and we'll merge this PR

@github-actions
Copy link
Contributor

Test results for "MCP"

3 failed
❌ [chromium] › mcp/launch.spec.ts:21 › test reopen browser @mcp-macos-15
❌ [chromium] › mcp/test-debug.spec.ts:48 › test_debug (pause/resume) @mcp-macos-15
❌ [chromium] › mcp/test-setup.spec.ts:105 › test_debug should run global setup and teardown @mcp-macos-15

2816 passed, 106 skipped


Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

28 failed
❌ [chromium-library] › library/agent-expect.spec.ts:243 › expectURL success @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-library] › library/agent-perform.spec.ts:106 › expect value @ubuntu-22.04-chromium-tip-of-tree
❌ [chromium-library] › library/agent-expect.spec.ts:243 › expectURL success @chromium-ubuntu-22.04-node24
❌ [chromium-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @chromium-ubuntu-22.04-node24
❌ [chromium-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @chromium-ubuntu-22.04-node24
❌ [chromium-library] › library/agent-perform.spec.ts:106 › expect value @chromium-ubuntu-22.04-node24
❌ [chromium-library] › library/agent-expect.spec.ts:243 › expectURL success @chromium-ubuntu-22.04-node20
❌ [chromium-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @chromium-ubuntu-22.04-node20
❌ [chromium-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @chromium-ubuntu-22.04-node20
❌ [chromium-library] › library/agent-perform.spec.ts:106 › expect value @chromium-ubuntu-22.04-node20
❌ [chromium-library] › library/agent-expect.spec.ts:243 › expectURL success @chromium-ubuntu-22.04-node22
❌ [chromium-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @chromium-ubuntu-22.04-node22
❌ [chromium-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @chromium-ubuntu-22.04-node22
❌ [chromium-library] › library/agent-perform.spec.ts:106 › expect value @chromium-ubuntu-22.04-node22
❌ [firefox-library] › library/agent-expect.spec.ts:243 › expectURL success @firefox-ubuntu-22.04-node20
❌ [firefox-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @firefox-ubuntu-22.04-node20
❌ [firefox-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @firefox-ubuntu-22.04-node20
❌ [firefox-library] › library/agent-perform.spec.ts:106 › expect value @firefox-ubuntu-22.04-node20
❌ [webkit-library] › library/agent-expect.spec.ts:243 › expectURL success @webkit-ubuntu-22.04-node20
❌ [webkit-library] › library/agent-expect.spec.ts:264 › expectURL wrong URL error @webkit-ubuntu-22.04-node20
❌ [webkit-library] › library/agent-limits.spec.ts:44 › should respect max actions limit @webkit-ubuntu-22.04-node20
❌ [webkit-library] › library/agent-perform.spec.ts:106 › expect value @webkit-ubuntu-22.04-node20
❌ [playwright-test] › playwright.ct-react.spec.ts:566 › should allow import from shared file @macos-latest-node20
❌ [playwright-test] › playwright.spec.ts:341 › should report error on timeout with shared page @macos-latest-node20
❌ [playwright-test] › playwright.trace.spec.ts:137 › should not throw with trace: on-first-retry and two retries in the same worker @macos-latest-node20
❌ [playwright-test] › ui-mode-test-network-tab.spec.ts:287 › should copy network request @windows-latest-node20

4 flaky ⚠️ [chromium-page] › page/page-history.spec.ts:95 › goBack/goForward should work with bfcache-able pages `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/popup.spec.ts:258 › should not throw when click closes popup `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1082 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:297 › should detect mime type `@webkit-ubuntu-22.04-node20`

34641 passed, 691 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants